#conding=utf-8
import sys
sys.path.append("D:/test/appium_po")
from appium import webdriver
from selenium.webdriver.remote.webdriver import WebDriver
from page.main_page import MainPage
from util.read_ini import ReadIni
from util.get_by_local import GetByLocal
from time import sleep

def get_driver():
    caps = {}
    caps["platformName"] = "android"
    caps["deviceName"] = "192.168.123.170:6666"
    caps["appPackage"] = "com.xqxc.customer"
    caps["appActivity"] = "com.xqxc.home_module.ui.activity.MainActivity"
    # caps["autoGrantPermissions"] = True
    caps["noReset"] = True
    caps["skipServerInstallation"] = True
    caps["skipDeviceInitialization"] = True
    driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
    driver.implicitly_wait(10)
    return driver
driver = get_driver()
def login(tel, password):
    # read_ini = ReadIni()
    # phone = read_ini.get_value('phone')
    get_by_local = GetByLocal(driver)
    el3 = get_by_local.get_element('phone')

    # el3 = driver.find_element_by_id(phone)
    el3.send_keys(tel)
    # el4 = driver.find_element_by_id("com.xqxc.customer:id/pwdEt")
    el4 = get_by_local.get_element("password")
    el4.send_keys(password)
    # el5 = driver.find_element_by_id("com.xqxc.customer:id/login_btn")
    el5 = get_by_local.get_element("login_button")
    el5.click()
    print("账号：%d登陆成功", tel)

sleep(10)
login('12500000025', '123456')
